package guiLayer.extensions;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

import modelLayer.Tree;

public class TreeCellRender extends DefaultListCellRenderer {
	private static final long serialVersionUID = 1L;
	private TreePanel tPanel;

	public TreeCellRender() {
		
	}
	
	@Override
	public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        Tree t = (Tree)value;
        String title = t.getSort() + " - " + t.getForest().getName();
        if(!isSelected){
        	tPanel = new TreePanel(title, Double.toString(t.getLifespan()), Double.toString(t.getSquareKilometer()), Double.toString(t.getCostPerSquareKilometer()), Double.toString(t.getRevenuePerSquareKilometer()), !isSelected);
        }else{
        	tPanel = new TreePanel(title, Double.toString(t.getLifespan()), Double.toString(t.getSquareKilometer()), Double.toString(t.getCostPerSquareKilometer()), Double.toString(t.getRevenuePerSquareKilometer()), !isSelected);
        }
        return tPanel;
	}
}
